package com.wudl.juc;

import java.sql.Time;
import java.util.concurrent.*;

/**
 * @author ：wudl
 * @date ：Created in 2021-11-28 23:28
 * @description：Callable 增强类
 * @modified By：
 * @version: 1.0
 */

public class MyCallableEnhance implements Callable<String> {
    @Override
    public String call() throws Exception {
        int i = 2 / 0;
        return "调用call 方法";
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {


        ThreadPoolExecutor executor = new ThreadPoolExecutor(5,5,1, TimeUnit.SECONDS,new ArrayBlockingQueue<>(10))
        {
            @Override
            protected void afterExecute(Runnable r, Throwable t) {
                System.out.println("call 调用执行完成---"+t.fillInStackTrace()+"---线程名称"+r.getClass());
            }
        };

        Future<String> future =executor.submit(new MyCallableEnhance());

        String s = future.get();
        System.out.println(s);
        executor.shutdown();





    }
}
